package cn.com.dcsgo.service.impl;

import cn.com.dcsgo.constant.CacheConstant;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.com.dcsgo.domain.Area;
import cn.com.dcsgo.service.AreaService;
import cn.com.dcsgo.mapper.AreaMapper;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 针对表【area】的数据库操作Service实现
 *
 * @author Dcsgo
 * @since 2025-10-26 13:09:56
 */
@Service
@CacheConfig(cacheNames = "cn.com.dcsgo.service.impl.AreaServiceImpl")
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area>
        implements AreaService {
    @Override
    @Cacheable(key = CacheConstant.ALL_AREA)
    public List<Area> list() {
        return super.list();
    }

    @Override
    @Cacheable(key = "#pid")
    public List<Area> listByPid(Long pid) {
        return list(
                new LambdaQueryWrapper<Area>()
                        .eq(Area::getParentId, pid)
                        .orderByAsc(Area::getAreaId)
        );
    }
}




